package test11;

public class SendGift extends Thread {
    public SendGift() {
    }

    public SendGift(String name) {
        super(name);
    }

    private static int count = 100;
    private static Object o = new Object();
    @Override
    public void run() {
        while (true){
            synchronized (o){
                if (count<10){
                    break;
                }else {
                    try {
                        Thread.sleep(100);
                        count--;
                        System.out.println(Thread.currentThread().getName()+
                                "在送礼物，还剩"+count+"个");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
